package com.lz.config;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * @Author 小思
 * @Description //TODO
 * @Date $ $
 * @Param $
 * @return $
 **/

public class MybatisConfig {
    //配置属性和加载数据源对象
    @Bean
    public SqlSessionFactoryBean sqlSessionFactoryBean(DataSource dataSource) {
        SqlSessionFactoryBean sql = new SqlSessionFactoryBean();
        sql.setTypeAliasesPackage("com.lz.domain");
        sql.setDataSource(dataSource);
        return sql;
    }

    //配置数据层接口
    @Bean
    public MapperScannerConfigurer mapperScannerConfigurer() {
        MapperScannerConfigurer ma = new MapperScannerConfigurer();
        ma.setBasePackage("com.lz.dao");
        return ma;
    }



}
